package cn.ccit.action;

import java.util.List;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ModelDriven;

import cn.ccit.base.BaseConstants;
import cn.ccit.entites.DiningTable;
import cn.ccit.iservers.IDiningTableServers;
import cn.ccit.model.BaseModel;
import cn.ccit.servers.DiningTableServers;

/**
 * 
 * @类功能说明：
 * @类修改者：
 * @修改日期：
 * @修改说明：
 * @公司名称：ccit
 * @作者：wanghao
 * @创建时间：2016年11月5日 上午1:48:14
 * @版本：V1.0
 */
public class DiningTableAction extends BaseAction implements
		ModelDriven<DiningTable> {
	/**
	 * @Fields serialVersionUID : 
	 */
	private static final long serialVersionUID = 1L;
	private IDiningTableServers itServers = new DiningTableServers();
	private DiningTable dt = new DiningTable();

	@Override
	public DiningTable getModel() {
		return dt;
	}

	@Override
	public String addData() {
		BaseModel<DiningTable> ba = new BaseModel<DiningTable>();
		sendJsonData(itServers.addDiningTable(dt), ba);
		return super.addData();
	}

	@Override
	public String removeData() {
		BaseModel<DiningTable> ba = new BaseModel<DiningTable>();
		sendJsonData(itServers.removeDiningTable(dt), ba);
		return super.removeData();
	}

	@Override
	public String changeDataInfo() {
		BaseModel<DiningTable> ba = new BaseModel<DiningTable>();
		sendJsonData(itServers.changeDiningTableInfo(dt), ba);
		return super.changeDataInfo();
	}

	@Override
	public String getDataList() {
		BaseModel<List<DiningTable>> ba = new BaseModel<List<DiningTable>>();
		sendJsonDataList(itServers.getSomeDiningTables(startId, limit), ba);
		return super.getDataList();
	}

	@Override
	public String sreachDataById() {
		DiningTable d=itServers.searchDiningTableByID(dt.getId());
		sendJsonData(d != null,
				new BaseModel<DiningTable>(),
				d);
		return super.sreachDataById();
	}

	@Override
	public String sreachDataByName() {
		sendJsonData(itServers.searchDiningTableByName(dt.getName()) != null,
				new BaseModel<DiningTable>());
		return super.sreachDataByName();
	}
	@Override
	public String changeDataState(){
		sendJsonData(itServers.changeDiningTableState(dt), new BaseModel<DiningTable>());
		return Action.SUCCESS;
	}
}
